const express = require("express");
const path = require("path");
const cors = require("cors");
const bodyParser = require('body-parser');
const db = require("./db/index");
const app=express();

app.use(express.static(path.join(__dirname, "public")));

app.use(cors());

app.use(bodyParser.urlencoded({
    extended: true
}));

app.use("/", async (req, res, next) => {
    await db;
    next();
  });
  
const loginres=require("./routes/login");
const hairProject=require("./routes/hairProject");
const memberLevel=require("./routes/memberLevel");
const customer = require('./routes/customer');
const message =require('./routes/message');
const recharge =require('./routes/recharge');
const performance=require('./routes/performance');

app.use(loginres);
app.use(hairProject);
app.use(memberLevel);
app.use(customer);
app.use(message);
app.use(recharge);
app.use(performance);



app.listen(8080,err=>{
    if(!err)console.log("服务器启动");
    else console.log(err);
})